-
Notifications
You must be signed in to change notification settings - Fork 4
Add EIS badges to Person Canvas (CFM-417) #364
base: develop
Are you sure you want to change the base?
Add EIS badges to Person Canvas (CFM-417) #364
Conversation
| @@ -90,6 +90,29 @@ public function beforeRender(\Cake\Event\EventInterface $event) { | |||
| $this->set('vv_default_name_type', $settings->default_name_type_id); | |||
| } | |||
|
|
|||
| if(!$this->request->is('restful') && $this->request->getParam('action') == 'edit') { | |||
| // Get the external identity sources for this person | |||
| $externalIdentitySources = $this->fetchTable('ExternalIdentities') | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look above we use TableRegistry and then run the find on the table as a second action. This is a bit more general of a solution (less work in contexts where we run multiple actions on a table, more generic where fetchTable() isn't a thing) though some older code does still use fetchTable(). Minimally, adjacent code shouldn't do the same thing two different ways.
| ->where(['ExternalIdentities.person_id' => $this->request->getParam('pass.0')]) | ||
| ->contain([ | ||
| 'ExtIdentitySourceRecords' => [ | ||
| 'ExternalIdentitySources' | ||
| ] | ||
| ]) | ||
| ->all(); | ||
|
|
||
| // Create a lookup table for badging EIS descriptions on Person Canvas MVEAS | ||
| $eisLookupTable = []; | ||
| foreach ($externalIdentitySources as $extIdentity) { | ||
| if (!empty($extIdentity->ext_identity_source_record) && | ||
| !empty($extIdentity->ext_identity_source_record->external_identity_source)) { | ||
| $eisLookupTable[$extIdentity->id] = $extIdentity->ext_identity_source_record->external_identity_source->description; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your query will be simpler if you always pull all EIS for the CO, instead of walking from the Person to the EIS Records that the Person is associated with. ie: you're doing more work to get a more exact answer, but it's probably an over-optimization. Something like
$ExternalIdentitySources = TableRegistry::getTableLocator()->get('ExternalIdentitySources');
$eis = $ExternalIdentitySources->find()->where('co_id' => $this->getCOID();
You can then use Cake's Hash utility to create your lookup table. I believe combine() will do what you want, but you should figure it out yourself because it will be a good learning experience :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reworked the query completely to produce the lookup table - including a switch to the TableRegistry approach. I still need to be able to relate the External Identity id with the External Identity Source description, and the new code does this more efficiently.
2ee926a to
d2585be
Compare
e4988db to
d4d04e4
Compare
|
The query to pull the External Identity Sources has been reworked using the TableRegistry and finding a list (to produce the lookup table in one shot). |
This PR adds External Identity Source descriptions to MVEAs on the person canvas (see screenshot). It does not currently take into account "Name" MVEAs, however. (And this PR will be marked as draft until that's addressed.)